<?php
	class Login extends Controller 
	{
		function Login()
		{
			parent::Controller();
			$this->load->model('login_model');
		}
		function index()
		{
			$this->load->view('login/login_view');													
		}
		function check_login()
		{
				if (empty($_POST['usrname']) || empty($_POST['pwd']))
			{
				redirect(WEB_URL . 'login/');
			}
			else
			{
				$usrname = $_POST['usrname'];
				$password = md5($_POST['pwd']);
				$user_id = $this->login_model->checkLogin(array($usrname, $password));
				if($user_id>0)
				{
				 redirect(WEB_URL . 'home/');
				}
				else
				{
				   redirect(WEB_URL . 'login/');
				}
			}	
				
			
			
		}
		function logout_action()
		{
			$this->session->sess_destroy();
			$sessionArray = array('uid'=>0,
			'usrname'=>'',
			'logged'=>FALSE);
			$this->session->set_userdata($sessionArray);					
			$_SESSION['uid'] = "0";

				redirect(WEB_URL . 'login/');
		}
	}	
?>